package com.example.novelstory.service.lxy;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.novelstory.dao.lxy.UserAuthorDao;
import com.example.novelstory.entity.Novel_author;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserAuthorServiceImpl extends ServiceImpl <UserAuthorDao,Novel_author>{
//    @Autowired
//    UserAuthorDao userAuthorDao;
//    @Override
//    public List<Novel_author> AllAuthor() {
//        List<Novel_author> novel_authors=userAuthorDao.AllAuthor();
//        return novel_authors;
//    }
//
//    @Override
//    public List<Novel> allNovel() {
//        List<Novel> novelList= userAuthorDao.allNovel();
//        return novelList;
//    }

//    @Override
    public List<Novel_author> findAuthor() {
//        List<Novel_author> novel_authors= userAuthorDao.findAuthor(author);
        return list();
    }
//
//    @Override
//    成为作者
    public boolean insertAnthor(Novel_author novel_author) {
//        String authortemp = author;
//        int novel_author = userAuthorDao.insertAnthor(author);
//        if (novel_author == 1) {
//            List<Novel_author> novel_authors = userAuthorDao.findAuthor(author);
//            return novel_authors;
//        } else {
//            System.out.println("注册失败");
//            return null;
//        }
        return save(novel_author);
    }

//    @Override
// 修改作者名字
    public boolean updateAuthor(Novel_author novel_author) {
//        int book=category;
//        int insertbook= userAuthorDao.insertBook(book, title, author);
//        if (insertbook==1){
//            List<Novel> novelList= userAuthorDao.allNovel();
//            return novelList;
//        }else {
//            System.out.println("发布失败");
//            return null;
//        }
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("author_id",novel_author.getAuthor_id());
        return update(novel_author,queryWrapper);
    }
//    注销作者身份

//    @Override
    public boolean deleteAuthor(Novel_author novel_author) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("author_name",novel_author.getAuthor_name());
        return remove(queryWrapper);
    }
}
